package com.macro.mall.controller;

import com.macro.mall.service.OmsOrderSettingService;
import com.macro.model.OmsOrderSetting;
import common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api("订单设置模块")
@Controller
@RequestMapping("/orderSetting")
public class OmsOrderSettingController {

    @Autowired
    private OmsOrderSettingService settingService;

    @ApiOperation("获取指定的设置")
    @GetMapping("/{id}")
    @ResponseBody
    public CommonResult<OmsOrderSetting> getItem(@PathVariable("id") Long id){
        return CommonResult.success(settingService.getItem(id));
    }



    @ApiOperation("更新指定的设置")
    @PostMapping("/update/{id}")
    @ResponseBody
    public CommonResult update(@PathVariable("id") Long id,
                      @RequestBody OmsOrderSetting setting){
        int count = settingService.update(id,setting);
        if(count > 0)
            return CommonResult.success(count);
        return CommonResult.failed();
    }
}
